<template>
  <section>
    <product-create v-if="is1688 && hasFetch" :formData.sync="createForm" @cancelCreate="cancel" @okCreate="ok" />
  </section>
</template>

<script>
    import {
        agency_is1688
    } from '../../api/agency';
export default {
  components: {
            'product-create': () => import('../../components/Product/create'),
  },
  data() {
    return {
      hasFetch: false,
      is1688: false,
      createForm: {
          product_id: 0,
          is_alibaba: true,
      },
      from: ""
    };
  },
  mounted() {
  },
        created() {
            agency_is1688().then((res)=>{
                this.is1688 = res.data == "1";
                this.hasFetch = true;

                if(this.is1688) {
                  this.createForm.product_id = parseInt(this.$route.query.id);
                  this.from = this.$route.query.from;
                }
            }).catch((err)=>{

            })
        },

  methods: {
    cancel() {
        // this.$router.push({path: '/company/vendors'});
    },
    ok() {
      if(this.from) {
        this.$router.push({path: '/' + this.from});
      } else {
        this.$router.push({path: '/goods_create'});
      }
    },
  }
};
</script>
